Skip to content

Conversation

jenken827
Copy link
Contributor

@jenken827 jenken827 commented Aug 20, 2025

很多网盘原生支持批量重命名和删除,但是目前openlist对于这两种操作是通过循环调用单次重命名和删除实现的,量大时效率非常低下,还容易导致失败(有些api有调用频率限制)。
修改点如下:
1.支持了原生批量重命名和删除
2.文件相关操作有大量重复的对于path的解析及鉴权代码,优化集中到中间件中
3.修复在批量重命名选择序列模式(第二个模式)时,如果文件本身没有扩展名,重命名后会多出一个"."的问题(前端)

Frontend: OpenListTeam/OpenList-Frontend#174

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors file operations to support native batch rename and remove operations instead of using inefficient loops, while centralizing path validation and authentication logic in middleware.

  • Adds support for native batch rename and batch remove operations through new driver interfaces
  • Consolidates duplicate path parsing and authentication code into reusable middleware functions
  • Implements batch operations for Baidu Netdisk and 123 Open cloud storage drivers

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/router.go Adds middleware to batch rename and remove endpoints
server/middlewares/fsup.go Removes old upload middleware (replaced by generic fs middleware)
server/middlewares/fs.go Creates new centralized middleware for file operations with path validation and authentication
server/handles/fsmanage.go Refactors remove handler to use batch operations and middleware context
server/handles/fsbatch.go Simplifies batch rename handler using new middleware and batch operations
internal/op/fs.go Adds BatchRemove function supporting native batch operations
internal/model/obj.go Defines new data structures for batch operations (IDName, RenameObj)
internal/fs/fs.go Implements BatchRename and BatchRemove functions with fallback to individual operations
internal/driver/driver.go Adds BatchRename and BatchRemove interfaces
internal/conf/const.go Adds StorageKey constant for context storage
drivers/baidu_netdisk/driver.go Implements BatchRename and BatchRemove for Baidu Netdisk
drivers/123_open/util.go Adds batch rename utility and modifies trash function for batch operations
drivers/123_open/driver.go Implements BatchRename and BatchRemove for 123 Open with chunking support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@xrgzs xrgzs changed the title refactor:batch remove and rename refactor(fs): batch remove and rename Aug 22, 2025
@xrgzs
Copy link
Member

xrgzs commented Aug 24, 2025

@hshpy
Copy link
Contributor

hshpy commented Aug 24, 2025

@jenken827
Copy link
Contributor Author

还有个批量正则重命名没处理 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L196 重命名前的文件名检测不能去掉 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L238

这个接口没有使用了吧!页面上使用正则批量命名时,前端会处理好正则,提交时,请求的是batch_rename接口。

@jenken827
Copy link
Contributor Author

@jenken827 请问能给 S3 驱动加一下吗

https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html

我先看下

@hshpy
Copy link
Contributor

hshpy commented Aug 29, 2025

还有个批量正则重命名没处理 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L196 重命名前的文件名检测不能去掉 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L238

这个接口没有使用了吧!页面上使用正则批量命名时,前端会处理好正则,提交时,请求的是batch_rename接口。

api文档有

@jenken827
Copy link
Contributor Author

还有个批量正则重命名没处理 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L196 重命名前的文件名检测不能去掉 https://github.com/OpenListTeam/OpenList/blob/main/server/handles/fsbatch.go#L238

这个接口没有使用了吧!页面上使用正则批量命名时,前端会处理好正则,提交时,请求的是batch_rename接口。

api文档有

这个接口我没改,保持原样就可以。

@jenken827
Copy link
Contributor Author

@jenken827 请问能给 S3 驱动加一下吗

https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html

我看了下目前s3批量删除的实现,是需要区分文件夹和文件的。我对s3不太熟悉,也没有s3账号,不太方便测试。最好是熟悉s3的开发。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants